<?php
/**
 * @author CptSoap
 * @email 694652150@qq.com
 * @date 2021/9/27
 * Json API 返回封装
 */

namespace app\admin\utils;

class jsonResult
{
    static public function result($code, $message = null, $data = null, $count = null): \think\response\Json
    {
        $result = array(
            'code' => $code,
        );
        if ($message != null) {
            $result['message'] = $message;
        }
        if ($data != null) {
            $result['data'] = $data;
        }
        if ($count != null) {
            $result['count'] = $count;
        }

        return json($result);
    }

}
